﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DC2010.Objects.Data;
using DC2010.Objects.Base;
using System.Xml.Serialization;

namespace DC2010.Objects.Structures
{
    public class TileDoorInfo : TileInfo
    {
        public TileDoorInfo()
        {
            GfxId = "DOOR_GFX_WOODEN_DOOR";
        }

        /// <summary>
        /// Is door open
        /// </summary>
        [XmlAttribute]
        public bool IsOpen { get; set; }

        /// <summary>
        /// 0 - cannot be picked
        /// 1 - very easy
        /// 100 / hard as hell
        /// </summary>
        [XmlAttribute]
        public int Picklockable { get; set; }

        /// <summary>
        /// Openable by button which is attached to frame
        /// </summary>
        [XmlAttribute]
        public bool ButtonFrame { get; set; }

        /// <summary>
        /// Is this teleporter visible?
        /// </summary>
        [XmlAttribute]
        public bool IsVisible { get; set; }

        /// <summary>
        /// When entered to this teleporter it makes sound
        /// </summary>
        [XmlAttribute]
        public bool MakesSound { get; set; }

        /// <summary>
        /// Teleporter is blining...while is not here it is not active :)
        /// This can be used for some speed runs.
        /// </summary>
        [XmlAttribute]
        public bool IsBlinking { get; set; }

        /// <summary>
        /// This telepporter actually teleports. It can be disabled using this property.
        /// </summary>
        [XmlAttribute]
        public bool IsEnabled { get; set; }

        /// <summary>
        /// How long is teleportter on, if blinking
        /// </summary>
        [XmlAttribute]
        public int Blink_DurationOn { get; set; }

        /// <summary>
        /// How long is teleportter off, if blinking
        /// </summary>
        [XmlAttribute]
        public int Blink_DurationOff { get; set; }

        /// <summary>
        /// How many times was teleporter on, if blinking
        /// </summary>
        [XmlAttribute]
        public int Blink_Counter { get; set; }

        /// <summary>
        /// Target in dungeon
        /// </summary>
        public DungeonLoc Target { get; set; }

        public override TileData CreateData()
        {
            TileTeleportData ttd = new TileTeleportData();

            ttd.InfoId = Id;
            ttd.Id = ttd.InfoId + "_" + Guid.NewGuid();
            //ttd.TeleportableTypes = TeleportableTypes;
            ttd.IsVisible = IsVisible;
            ttd.MakesSound = MakesSound;
            ttd.IsBlinking = IsBlinking;
            ttd.IsEnabled = IsEnabled;
            ttd.Blink_DurationOn = Blink_DurationOn;
            ttd.Blink_DurationOff = Blink_DurationOff;
            ttd.Blink_Counter = Blink_Counter;
            ttd.Target = (DungeonLoc)Target.Clone();


            //TODO: fill with other properties
            Root.log.InfoFormat("Core, Created new teleport tile with id: {0} based on object {1}", ttd.Id, ttd.InfoId);
            Root.I.TileSystem.AddData(ttd);


            return ttd;
        }
    }
}
